# Contributor: Michał Polański <michal@polanski.me>
# Maintainer: Michał Polański <michal@polanski.me>
pkgname=prettier
pkgver=2.7.1
pkgrel=0
pkgdesc="Opinionated code formatter"
url="https://prettier.io/"
license="MIT"
# riscv64: blocked by nodejs
# armhf, armv7, x86: fails to build on 32-bit arches
arch="noarch !armhf !armv7 !riscv64 !x86"
depends="nodejs"
makedepends="yarn"
checkdepends="npm"
subpackages="$pkgname-doc"
source="https://github.com/prettier/prettier/archive/$pkgver/prettier-$pkgver.tar.gz
	timeout.patch
	"

build() {
	yarn install --frozen-lockfile
	yarn build
}

check() {
	yarn test:dist
}

package() {
	local destdir=/usr/lib/node_modules/prettier

	install -d \
		"$pkgdir"/usr/bin \
		"$pkgdir"/$destdir \
		"$pkgdir"/usr/share/licenses/prettier

	cp -r dist/* "$pkgdir"/$destdir
	ln -s $destdir/bin-prettier.js "$pkgdir"/usr/bin/prettier

	cd "$pkgdir"/$destdir
	rm -r esm # remove ES modules: not needed for command-line usage
	rm README.md # more links to various badges than actual content
	mv LICENSE "$pkgdir"/usr/share/licenses/prettier/LICENSE
}

sha512sums="
ce6532d9bdbdbb3d8bbc1ed49a5de7ac6396120f87622ec14bd0a6b2e9e5f20c4f72daa225e0a7ff1fb1a41316402327e52316906f48146e966bc5ef95726391  prettier-2.7.1.tar.gz
06968fc076d2cd68360601c84c49b82a1f872a1b54d5ec9738de7ac63793f96cd609817bbb0a0f1902b7ba004232d1276b3577557dc60dd2a7d71fad5e440099  timeout.patch
"
